import axios from '@/libs/api.request'
/**
 * getDictionaryList  字典代码分页查询
 */
export const getDictionaryList = (data) => {
  return axios.request({
    url: '/gas/domain/dict/list',
    data: JSON.stringify(data),
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * dictionaryAdd  新增字典代码
 */
export const dictionaryAdd = (obj) => {
  return axios.request({
    url: '/gas/domain/dict/add',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * dictionaryUpdate  修改字典代码
 */
export const dictionaryUpdate = (obj) => {
  return axios.request({
    url: '/gas/domain/dict/update',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * dictionaryDelete  删除字典代码
 */
export const dictionaryDelete = (dictId) => {
  return axios.request({
    url: '/gas/domain/dict/delete',
    data: dictId,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * getDictInfoByIdById  根据ID获取字典代码
 */
export const getDictInfoByIdById = (id) => {
  return axios.request({
    url: '/gas/domain/dict/getDictInfoByIdById',
    data: JSON.stringify({ 'dictId': id }),
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * dictGroupAdd  新增字典分组--------------------------------------------
 */
export const dictGroupAdd = (obj) => {
  return axios.request({
    url: '/gas/domain/dictGroup/add',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * dictGroupUpdate  修改字典分组
 */
export const dictGroupUpdate = (obj) => {
  return axios.request({
    url: '/gas/domain/dictGroup/update',
    data: obj,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * dictGroupDelete  删除字典分组
 */
export const dictGroupDelete = (groupId) => {
  return axios.request({
    url: '/gas/domain/dictGroup/delete',
    data: groupId,
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * dictGroupList  字典分组分页查询
 */
export const dictGroupList = (data) => {
  return axios.request({
    url: '/gas/domain/dictGroup/list',
    data: JSON.stringify(data),
    method: 'post',
    headers: {
      'Content-type': 'application/json'
    }
  })
}

/**
 * getDictListByGroupCodes (获取多个分组的字典数据
 * @param {Array}  groupCodeList
 * {"groupCodeList":["educationLevel","gender"], domainId?: 1}
 */
export const getDictListByGroupCodes = ({ groupCodeList, isPubFlag }) => {
  let data = isPubFlag ? { groupCodeList, domainId: 1 } : { groupCodeList }
  return axios.request({
    url: '/gas/domain/dict/getDictListByGroupCodes',
    data: data,
    method: 'post'
  })
}
